//
//  RCServerCheckPhotoListModel.m
//  RocketProject
//
//  Created by chen jiedan on 13-9-29.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCServerCheckPhotoListModel.h"
#import "KFObjectExtension.h"






@implementation RCServerCheckPhotoItemModel

@synthesize photoID = _photoID;
@synthesize name = _name;
@synthesize type = _type;
@synthesize picUrl = _picUrl;
@synthesize dateTime = _dateTime;

- (void) dealloc
{
    KF_RELEASE_SAFELY(_photoID);
    KF_RELEASE_SAFELY(_name);
    KF_RELEASE_SAFELY(_type);
    KF_RELEASE_SAFELY(_picUrl);
    KF_RELEASE_SAFELY(_dateTime);

    [super dealloc];
}
@end


@implementation RCServerCheckPhotoListModel


// 将JSON数据解析为数据模型
+(id) parseDataFromJSON:(NSDictionary*)data
{
    // 输入参数判断
    if ( nil == data )
        return nil;
    NSMutableArray *listItems = [[NSMutableArray alloc] init];
    
    RCServerCheckPhotoListModel *retObject = [[[RCServerCheckPhotoListModel alloc] init] autorelease];
    NSDictionary *dataDic = [data dictionaryValueForKey:@"data" defaultValue:nil];
    retObject.pn     = [dataDic intValueForKey:@"pn" defaultValue:0];
    retObject.rn     = [dataDic intValueForKey:@"rn" defaultValue:0];
    retObject.total  = [dataDic intValueForKey:@"total" defaultValue:0];
    
    NSArray *dataItems = [dataDic arrayValueForKey:@"list" defaultValue:nil];
    if (nil == dataItems) {
        dataItems = [dataDic arrayValueForKey:@"items" defaultValue:nil];
    }
    for (NSDictionary *dic in dataItems) {
        RCServerCheckPhotoItemModel *item = [[RCServerCheckPhotoItemModel alloc] init];
        item.photoID = [dic stringValueForKey:@"id" defaultValue:@"" operation:NSStringOperationTypeNone];
        item.name = [dic stringValueForKey:@"name" defaultValue:@"" operation:NSStringOperationTypeNone];
        item.picUrl = [dic stringValueForKey:@"picurl" defaultValue:@"" operation:NSStringOperationTypeNone];
        item.type = [dic stringValueForKey:@"type" defaultValue:@"" operation:NSStringOperationTypeNone];
        item.dateTime = [dic stringValueForKey:@"datetime" defaultValue:@"" operation:NSStringOperationTypeNone];

        [listItems addObject:item];
        [item release];
    }
    retObject.listItems = listItems;
    [listItems release];
    return retObject;
}


@end
